package com.string_;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class String2Array {
    public static void main(String[] args) {
        String[] str1 = {"aa", "bb", "cc"};
        method1(str1);
        method2(str1);
        method3(str1);

    }

    public static void method1(String[] str1) {
        //String数组转List
        List<String> strsToList1 = Arrays.asList(str1);
        System.out.println("----method1----");
        for (String s : strsToList1) {
            System.out.println(s);
        }

    }

    public static void method2(String[] str1) {
        //String数组转List
        List<String> strsToList2 = new ArrayList<>();
        Collections.addAll(strsToList2, str1);
        System.out.println("----method2 ----");
        for (String s : strsToList2) {
            System.out.println(s);
        }

    }

    public static void method3(String[] str1) {
        //String数组转List
        List<String> strsToList3 = new ArrayList<>();
        for (String s : str1) {
            strsToList3.add(s);
        }
        System.out.println("----method3----");
        for (String s : strsToList3) {
            System.out.println(s);
        }
    }
}
